﻿using CefSharp;
using CefSharp.Handler;
using CefSharp.WinForms;
using CefSharp.WinForms.Handler;
using JLModel;
using JLWebBrowser.BLL;
using JLWebBrowser.Properties;
using System.Diagnostics;
using System.Net;
using System.Security.Policy;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace JLWebBrowser
{
    public partial class FrmMain : Form
    {
        public static FrmMain frmMain;

        private TabControl tabControl;

        private List<ChromiumWebBrowser> browsers = new List<ChromiumWebBrowser>();


        private readonly double minusZoom = -7.6;
        private readonly double positiveZoom = 8;
        private readonly double zoomLevelIncrement = 0.1;

        public FrmMain()
        {
            InitializeComponent();
            InitializeChromium();
            this.Icon = Properties.Resources.browser;
            frmMain = this;
        }

        public void AddTab(string url)
        {

            TabPage page = tabControl.TabPages[0];
            if (page != null && page.Tag != null)
            {
                (page.Tag as TabInfo).Browser.Load(txtURL.Text);
            }

            ChromiumWebBrowser browser = new ChromiumWebBrowser(url);

            //实例化控件
            browser = new ChromiumWebBrowser();
            //设置停靠方式
            browser.Dock = DockStyle.Fill;

            browser.MenuHandler = new MenuHandler();

            //browser.Load("https://www.baidu.com");

            //加载开始事件
            browser.FrameLoadStart += Browser_FrameLoadStart;

            browser.AddressChanged += Browser_AddressChanged;

            browser.TitleChanged += Browser_TitleChanged;

            browser.FrameLoadEnd += webBrowser_FrameLoadEndEventArgs;

            browser.RequestHandler = new WinFormsRequestHandler();//request请求的具体实现

            browser.KeyboardHandler = new CEFKeyBoardHander();

            browser.LifeSpanHandler = CefSharp.WinForms.Handler.LifeSpanHandler
                        .Create()
                        .OnBeforePopupCreated((chromiumWebBrowser, b, frame, targetUrl, targetFrameName, targetDisposition, userGesture, browserSettings) =>
                        {
                            if (string.IsNullOrWhiteSpace(targetUrl))
                            {
                                return PopupCreation.Continue;
                            }
                            else
                            {
                                this.Invoke(new Action(() =>
                                {
                                    this.AddTab(targetUrl);
                                }));

                                return PopupCreation.Cancel;
                            }
                        }).Build();

            browser.Load(url);

            browsers.Add(browser);

            SplitContainer splitContainer1 = new SplitContainer();

            splitContainer1.Dock = DockStyle.Fill;
            splitContainer1.Location = new Point(0, 0);
            splitContainer1.SplitterDistance = this.Width;

            splitContainer1.Panel2MinSize = 0;

            TabInfo tabInfo = new TabInfo();
            tabInfo.Browser = browser;
            tabInfo.DevPanel = splitContainer1;
            tabInfo.URL = "";
            tabInfo.Title = "空页面";


            TabPage tabPage = new TabPage(url);
            tabPage.Tag = tabInfo;
            tabPage.Resize += TabPage_Resize;


            tabPage.Controls.Add(browser);
            tabControl.TabPages.Insert(0, tabPage);

            tabControl.SelectedIndex = 0;
        }

        /// <summary>
        /// 页面大小改变触发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TabPage_Resize(object? sender, EventArgs e)
        {


        }

        /// <summary>
        /// 初始化浏览器
        /// </summary>
        private void InitializeChromium()
        {

            var setting = new CefSettings();
            // 设置语言
            setting.Locale = "zh-CN";
            setting.AcceptLanguageList = "zh-CN";
            setting.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36";
            setting.CefCommandLineArgs.Add("disable-gpu", "1");//去掉gpu，否则chrome显示有问题

            Cef.Initialize(setting, true);

            Cef.EnableHighDPISupport();



            tabControl = new TabControl();
            tabControl.DrawMode = TabDrawMode.OwnerDrawFixed;
            tabControl.Dock = DockStyle.Fill;
            tabControl.SizeMode = TabSizeMode.Fixed;
            tabControl.ItemSize = new Size(150, 0);
            tabControl.Multiline = true;
            tabControl.DrawItem += TabControl_DrawItem;
            tabControl.MouseDown += TabControl_MouseDown;

            TabPage tabPage = new TabPage("添加新页面");
            tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;
            tabControl.TabPages.Add(tabPage);

            //加入到当前窗体中
            pnlWebBrowser.Controls.Add(tabControl);

            //if (!string.IsNullOrWhiteSpace(CommonBLL.DefaultURL))
            //{
            //    browser.Load(CommonBLL.DefaultURL);
            //}
        }

        private void TabControl_SelectedIndexChanged(object? sender, EventArgs e)
        {
            if (tabControl.SelectedIndex == tabControl.TabCount - 1)
            {
                AddTab("");
            }
            else
            {
                TabPage tabpage = tabControl.TabPages[tabControl.SelectedIndex];

                if (tabpage.Tag != null)
                {
                    TabInfo tabinfo = (tabpage.Tag as TabInfo);
                    this.txtURL.Text = tabinfo.URL;
                    this.Text = tabinfo.Title;
                }


            }
        }

        /// <summary>
        /// 点击Tab的叉号关闭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TabControl_MouseDown(object? sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                return;
            }

            TabPage page = (sender as TabControl).SelectedTab;
            Rectangle rect = (sender as TabControl).GetTabRect((sender as TabControl).SelectedIndex);
            Rectangle rect1 = new Rectangle(rect.Right - 22, rect.Y, 22, rect.Height);
            int x = e.X;
            int y = e.Y;
            //判断鼠标位置是否位于“❌”的范围内
            if (x > rect1.X && x < rect1.Right && y > rect1.Y && y < rect1.Bottom)
            {
                //(page.Tag as TabInfo).Browser.Dispose();
                (sender as TabControl).TabPages.Remove(page);
            }
        }

        /// <summary>
        /// 给Tab增加关闭按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TabControl_DrawItem(object? sender, DrawItemEventArgs e)
        {
            /*如果将 DrawMode 属性设置为 OwnerDrawFixed，  则每当 TabControl 需要绘制它的一个选项卡时，它就会引发 DrawItem 事件*/
            try
            {

                Graphics graphics = e.Graphics;
                graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                Rectangle rect = (sender as TabControl).GetTabRect(e.Index);
                TabPage page = (sender as TabControl).TabPages[e.Index];
                SolidBrush brushBack;
                SolidBrush brushFront;
                string text = page.Text;
                //if (e.Index == (sender as TabControl).TabCount - 1)
                //{
                //    text = "+";
                //}

                //TabPage被选中时显示不同的前景色和背景色
                if ((sender as TabControl).SelectedTab == page)
                {
                    brushBack = new SolidBrush(Color.White);
                    brushFront = new SolidBrush(Color.Black);
                }
                else
                {
                    brushBack = new SolidBrush(Color.White);
                    brushFront = new SolidBrush(Color.Black);
                }
                graphics.FillRectangle(brushBack, rect);

                StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Near;
                sf.LineAlignment = StringAlignment.Center;
                sf.FormatFlags = StringFormatFlags.LineLimit;



                if (e.Index != (sender as TabControl).TabCount - 1)
                {
                    graphics.DrawString(text, new Font("宋体", 10f), brushFront, new Rectangle(rect.Left + 2, rect.Top + 2, rect.Width - 22, rect.Bottom - 2), sf);
                    Font font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                    graphics.DrawString("×", font, brushFront, rect.Right - 22, rect.Bottom - 18);
                }
                else
                {
                    graphics.DrawString(text, new Font("宋体", 10f), brushFront, new Rectangle(rect.Left + 2, rect.Top + 2, rect.Width - 22, rect.Bottom - 2), sf);
                }

                e.Dispose();
            }
            catch (Exception ex)
            {

            }
        }

        private void Browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e)
        {

        }

        private void Browser_AddressChanged(object sender, AddressChangedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(e.Address))
            {
                return;
            }

            foreach (TabPage tabpage in tabControl.TabPages)
            {
                if (tabpage.Tag == null)
                {
                    continue;
                }
                TabInfo tabinfo = (tabpage.Tag as TabInfo);
                if (tabinfo.Browser == sender)
                {
                    tabinfo.URL = e.Address;
                }
            }
            txtURL.Text = e.Address;
        }

        private void Browser_TitleChanged(object sender, TitleChangedEventArgs e)
        {
            this.Text = e.Title;

            foreach (TabPage tabpage in tabControl.TabPages)
            {
                if (tabpage.Tag == null)
                {
                    continue;
                }
                TabInfo tabinfo = (tabpage.Tag as TabInfo);
                if (tabinfo.Browser == sender)
                {
                    tabpage.Text = e.Title;
                    tabinfo.Title = e.Title;
                }
            }
        }


        /// <summary>
        /// 页面加载完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void webBrowser_FrameLoadEndEventArgs(object sender, FrameLoadEndEventArgs e)
        {

            string htmlstr = string.Empty;
            Debug.WriteLine(e.Frame.Name);
            if (e.Frame.IsMain)
            {
                (sender as ChromiumWebBrowser).GetSourceAsync().ContinueWith(taskHtml =>
                {
                    htmlstr = taskHtml.Result;

                    //Debug.WriteLine(htmlstr);
                });
            }

        }



        /// <summary>
        /// 禁用右键菜单
        /// </summary>
        internal class MenuHandler : IContextMenuHandler
        {

            public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
            {
                model.Clear();

                // 判断是否右键单击了图像
                if (!string.IsNullOrWhiteSpace(parameters.LinkUrl))
                {
                    // 添加一个自定义菜单项
                    model.AddItem((CefMenuCommand)26506, "在新标签页打开");
                }

                // 判断是否右键单击了图像
                if (parameters.MediaType == ContextMenuMediaType.Image)
                {
                    // 添加一个自定义菜单项
                    model.AddItem((CefMenuCommand)26505, "下载图像");
                }
                model.AddItem((CefMenuCommand)26501, "前进");
                model.AddItem((CefMenuCommand)26502, "后退");
                model.AddSeparator();//添加分隔符
                model.AddItem((CefMenuCommand)26504, "打印");
                model.AddItem((CefMenuCommand)26503, "刷新");
            }

            public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
            {
                if (commandId == (CefMenuCommand)26501)
                {
                    browser.GoForward();
                    return true;
                }
                if (commandId == (CefMenuCommand)26502)
                {
                    browser.GoBack();
                    return true;
                }
                if (commandId == (CefMenuCommand)26503)
                {
                    browser.Reload(true);
                    return true;
                }
                if (commandId == (CefMenuCommand)26504)
                {
                    browser.Print();
                    return true;
                }
                if (commandId == (CefMenuCommand)26505)
                {
                    // 获取图像的URL
                    string imageUrl = parameters.SourceUrl;

                    // 下载图像
                    DownloadImage(imageUrl);
                    return true;
                }
                if (commandId == (CefMenuCommand)26506)
                {
                    string url = parameters.LinkUrl;
                    //在新标签页打开
                    frmMain.Invoke(new Action(() =>
                    {
                        frmMain.AddTab(url);
                    }));

                    return true;
                }
                return false;
            }

            private void DownloadImage(string imageUrl)
            {
                using (WebClient client = new WebClient())
                {
                    // 生成保存图像的文件名
                    string fileName = Path.GetFileName(imageUrl);

                    // 下载图像到本地文件系统
                    client.DownloadFile(imageUrl, fileName);
                }
            }

            public void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame)
            {

            }

            public bool RunContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback)
            {
                return false;
            }
        }

        /// <summary>
        /// 拦截请求
        /// </summary>
        internal class WinFormsRequestHandler : RequestHandler
        {
            protected override IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling)
            {
                //NOTE: In most cases you examine the request.Url and only handle requests you are interested in
                if (request.Url.ToLower().Contains("login".ToLower()))
                {
                    using (var postData = request.PostData)
                    {
                        if (postData != null)
                        {
                            var elements = postData.Elements;

                            var charSet = request.GetCharSet();

                            foreach (var element in elements)
                            {
                                if (element.Type == PostDataElementType.Bytes)
                                {
                                    //请求返回内容
                                    var body = element.GetBody(charSet);
                                    Debug.WriteLine(body);
                                }
                            }
                        }
                    }
                }
                return null;
            }

        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            //必须在浏览器控件初始化后最大化窗体，否则会打开多个多余窗体
            this.WindowState = FormWindowState.Maximized;
            Control.CheckForIllegalCrossThreadCalls = false;

            AddTab(CommonBLL.DefaultURL);
            FavoritesBLL.FavoritesListGet();
            if (FavoritesBLL.FavoritesList != null)
            {
                FavoritesMmenuDirInit(null, FavoritesBLL.FavoritesList.FindAll(m => m.FID == 0));
            }

        }

        /// <summary>
        /// 关闭窗口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                Cef.Shutdown();
            }
            catch
            {

            }
        }

        /// <summary>
        /// 设置Cookie
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        private void SetCookie(string domain, string key, string value)
        {
            var cookieManager = CefSharp.Cef.GetGlobalCookieManager();
            cookieManager.SetCookieAsync("http://localhost", new CefSharp.Cookie()
            {
                Domain = domain,//这里是localhost，就会出现设置的值和HTML中的值
                Name = key,
                Value = value,
                Expires = DateTime.MinValue
            });
        }

        /// <summary>
        /// 执行脚本
        /// </summary>
        /// <param name="script"></param>
        /// <param name="frame"></param>
        private void RunJavaScript(string script, IFrame frame = null)
        {
            if (frame == null)
            {
                TabPage page = tabControl.SelectedTab;
                if (page != null && page.Tag != null)
                {
                    (page.Tag as TabInfo).Browser.GetBrowser().MainFrame.ExecuteJavaScriptAsync(script);
                }
            }
            else
            {
                frame.ExecuteJavaScriptAsync(script);
            }


        }

        /// <summary>
        /// 跳转到
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGoPage_Click(object sender, EventArgs e)
        {
            TabPage page = tabControl.SelectedTab;
            if (page != null && page.Tag != null)
            {
                (page.Tag as TabInfo).Browser.Load(txtURL.Text);
            }
        }

        /// <summary>
        /// 后退
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPageBack_Click(object sender, EventArgs e)
        {
            TabPage page = tabControl.SelectedTab;
            if (page != null && page.Tag != null)
            {
                (page.Tag as TabInfo).Browser.Back();
            }
        }

        /// <summary>
        /// 前进
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPageBefore_Click(object sender, EventArgs e)
        {
            TabPage page = tabControl.SelectedTab;
            if (page != null && page.Tag != null)
            {
                (page.Tag as TabInfo).Browser.Forward();
            }
        }

        /// <summary>
        /// 网址输入框回车
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtURL_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {

                if (!string.IsNullOrWhiteSpace(txtURL.Text))
                {
                    if (e.Control)
                    {
                        if (txtURL.Text.IndexOf(".com") < 0)
                        {
                            txtURL.Text = "www." + txtURL.Text + ".com";
                        }
                    }
                    TabPage page = tabControl.SelectedTab;
                    if (page != null && page.Tag != null)
                    {
                        (page.Tag as TabInfo).Browser.Load(txtURL.Text);
                    }
                }
            }

        }

        private void miSetZoom_Click(object sender, EventArgs e)
        {
            SetZoom(Convert.ToInt32((sender as ToolStripMenuItem).Tag));
        }

        /// <summary>
        /// 设置浏览器显示比例
        /// </summary>
        /// <param name="percent">百分比</param>
        private async void SetZoom(int percent)
        {
            TabPage page = tabControl.SelectedTab;
            if (page != null && page.Tag != null)
            {

                double currentLevel = Math.Log(percent / 100, 1.2);
                //double zoomLevel = await (page.Tag as ChromiumWebBrowser).GetZoomLevelAsync();

                if (currentLevel >= positiveZoom)
                {
                    (page.Tag as TabInfo).Browser.SetZoomLevel(positiveZoom);

                }
                else if (currentLevel <= minusZoom)
                {
                    (page.Tag as TabInfo).Browser.SetZoomLevel(minusZoom);
                }
                else
                {
                    (page.Tag as TabInfo).Browser.SetZoomLevel(currentLevel);
                }
            }

        }

        private void miExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnPageBack_MouseEnter(object sender, EventArgs e)
        {
            (sender as Panel).BackColor = Color.White;
        }

        private void btnPageBack_MouseLeave(object sender, EventArgs e)
        {
            (sender as Panel).BackColor = SystemColors.Control;
        }

        private void miDev_Click(object sender, EventArgs e)
        {
            TabPage page = tabControl.SelectedTab;
            if (page != null && page.Tag != null)
            {
                TabInfo info = page.Tag as TabInfo;
                if (page.Controls.Contains(info.Browser))
                {
                    page.Controls.Remove(info.Browser);
                    info.DevPanel.Panel1.Controls.Add(info.Browser);
                    page.Controls.Add(info.DevPanel);
                    info.DevPanel.SplitterDistance = page.Width / 3 * 2;
                    (page.Tag as TabInfo).Browser.ShowDevToolsDocked((page.Tag as TabInfo).DevPanel.Panel2, "DevPanel_" + Guid.NewGuid().ToString(), DockStyle.Fill);
                }
                else
                {
                    page.Controls.Remove(info.DevPanel);
                    page.Controls.Add(info.Browser);
                }


            }
        }

        private void miFavoritesAdd_Click(object sender, EventArgs e)
        {
            TabPage page = tabControl.SelectedTab;
            if (page != null && page.Tag != null)
            {
                TabInfo info = page.Tag as TabInfo;
                FavoritesModel favorite = null;
                if (FavoritesBLL.FavoritesList != null)
                {
                    FavoritesBLL.FavoritesList.Find(m => m.URL == info.URL);
                }

                if (favorite == null)
                {
                    favorite = new FavoritesModel();
                    favorite.FID = 0;
                    favorite.URL = info.URL;
                    favorite.Name = info.Title;
                    favorite.DataType = "U";
                    FavoritesBLL.FavoritesAdd(favorite);
                }

                // 添加子菜单项
                ToolStripMenuItem miURL = new ToolStripMenuItem();
                miURL.Text = favorite.Name;
                miURL.Tag = favorite;
                miURL.Click += miFavorites_Click;
                miURL.MouseUp += MiURL_MouseUp;
                miFavorites.DropDownItems.Add(miURL);
            }

        }

        private void miFavorites_Click(object? sender, EventArgs e)
        {
            FavoritesModel favorite = (sender as ToolStripMenuItem).Tag as FavoritesModel;
            if (favorite != null)
            {
                this.AddTab(favorite.URL);
            }
        }

        private void FavoritesMmenuDirInit(ToolStripMenuItem mi, List<FavoritesModel> favoritesList)
        {
            if (favoritesList == null)
            {
                return;
            }
            favoritesList = favoritesList.OrderBy(m => m.DataType).ToList();
            foreach (FavoritesModel favorite in favoritesList)
            {
                ToolStripMenuItem miURL = new ToolStripMenuItem();
                if (favorite.DataType == "D")
                {
                    miURL.Text = favorite.Name;
                    miURL.Tag = favorite;
                    List<FavoritesModel> itemList = FavoritesBLL.FavoritesList.FindAll(m => m.FID == favorite.ID);
                    if (itemList != null)
                    {
                        FavoritesMmenuDirInit(miURL, itemList);
                    }
                }
                else if (favorite.DataType == "U")
                {
                    miURL.Text = favorite.Name;
                    miURL.Tag = favorite;
                    miURL.Click += miFavorites_Click;
                    miURL.MouseUp += MiURL_MouseUp;
                }
                if (mi == null)
                {
                    miFavorites.DropDownItems.Add(miURL);
                }
                else
                {
                    mi.DropDownItems.Add(miURL);
                }
            }
        }

        private void MiURL_MouseUp(object? sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {

                Point point = Control.MousePosition;
                miFavoritesDelete.Tag = (sender as ToolStripMenuItem).Tag;
                menuFavorites.Show(point);
            }
        }

        private void miFavoritesDelete_Click(object sender, EventArgs e)
        {
            FavoritesModel favorite = (sender as ToolStripMenuItem).Tag as FavoritesModel;
            if (favorite != null)
            {
                if (FavoritesBLL.FavoritesDelete(favorite))
                {
                    foreach (var item in miFavorites.DropDownItems)
                    {

                        if (item.GetType().ToString().IndexOf("ToolStripMenuItem") > -1)
                        {
                            if ((item as ToolStripMenuItem).Tag == favorite)
                            {
                                miFavorites.DropDownItems.Remove((item as ToolStripMenuItem));
                                break;
                            }
                        }


                    }
                    FavoritesBLL.FavoritesList.Remove(favorite);
                }
            }
        }
    }


    public class CEFKeyBoardHander : IKeyboardHandler
    {

        public bool OnKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
        {
            if (type == KeyType.KeyUp && Enum.IsDefined(typeof(Keys), windowsKeyCode))
            {
                var key = (Keys)windowsKeyCode;
                switch (key)
                {
                    case Keys.F12:
                        chromiumWebBrowser.ShowDevTools();
                        break;

                    case Keys.F5:

                        if (modifiers == CefEventFlags.ControlDown)
                        {
                            //MessageBox.Show("ctrl+f5");
                            browser.Reload(true); //强制忽略缓存

                        }
                        else
                        {
                            //MessageBox.Show("f5");
                            browser.Reload();
                        }
                        break;
                }
            }
            return false;
            // throw new NotImplementedException();
        }

        public bool OnPreKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
        {
            return false;
            //throw new NotImplementedException();
        }
    }

    public class TabInfo
    {
        /// <summary>
        /// 浏览器组件
        /// </summary>
        public ChromiumWebBrowser Browser { get; set; }

        /// <summary>
        /// 开发者组件Panel
        /// </summary>
        public SplitContainer DevPanel { get; set; }

        /// <summary>
        /// 打开的网址
        /// </summary>
        public string URL { get; set; }

        /// <summary>
        /// 页面标题
        /// </summary>
        public string Title { get; set; }
    }
}